﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BussinesCosea;
using System.Configuration;

public partial class IngresoEmpleado : System.Web.UI.Page
{

    private static AppSettingsReader settings = new AppSettingsReader();
    string cadena = (string)settings.GetValue("Conexion2", typeof(string));

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnConsultar_Click(object sender, EventArgs e)
    {
        cargaGridOK();
    }

    private void cargaGridOK()
    {
        string criterio = "";

        if (Documentacion_9.Checked)
            criterio = "";
        else
            criterio = cname.Value.Trim();

        using (BussinesCosea.CoseaDirectos c = new BussinesCosea.CoseaDirectos(cadena))
        {
            grdDatos.DataSource = c.BuscaPrecandidatos(criterio);
            grdDatos.DataBind();
        }
    }

    private void cargaGridActivos()
    {
        string criterio = "";

        if (Checkbox1.Checked)
            criterio = "";
        else
            criterio = Text1.Value.Trim();

        using (BussinesCosea.CoseaDirectos c = new BussinesCosea.CoseaDirectos(cadena))
        {
            grdDatos.DataSource = c.BuscaActivosEmp(criterio);
            grdDatos.DataBind();
        }
    }

    private void cargaGridInActivos()
    {
        string criterio = "";

        if (Checkbox2.Checked)
            criterio = "";
        else
            criterio = Text2.Value.Trim();

        using (BussinesCosea.CoseaDirectos c = new BussinesCosea.CoseaDirectos(cadena))
        {
            grdDatos.DataSource = c.BuscaINActivosEmp(criterio);
            grdDatos.DataBind();
        }
    }

    protected void grdDatos_SelectedIndexChanged1(object sender, EventArgs e)
    {
        string id = grdDatos.SelectedValue.ToString();
        Response.Redirect("incidencias.aspx?id=" + id);  
    }
    protected void grdDatos_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdDatos.PageIndex = e.NewPageIndex;
        cargaGridOK();
    }
    protected void btnConsultar1_Click(object sender, EventArgs e)
    {
        cargaGridActivos();
    }
    protected void btnConsultar2_Click(object sender, EventArgs e)
    {
        cargaGridInActivos();
    }
}